<?php
session_start();
ob_start();

define('INDEX',true);
// Include required files
require("../_config/config.php");
require("../_config/db_connection.php");
require("../common/functions_common.php");
require("../common/functions_mysql.php");
require("../common/functions_jcas.php");
require("../common/init.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
<HTML  >
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="MSThemeCompatible" content="Yes">
<meta name="copyright" content="Huynh Ngoc Hung (c) 2004">
<TITLE>Change password</TITLE>
<style>
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color:#333333;
}
.button
{
font-size:11px;
padding:1px 1px 1px 1px;
font-family:tahoma ;
cursor:hand
}
</style>
</head>

<BODY id=bdy style="background: threedface; color: windowtext;" scroll=no>
<?php
// Upload file
if(check_post("update,old_pwd,new_pwd"))
{
	if ($admin_session['admin_pwd'] == md5(md5($_POST['old_pwd']))) 
	{
		 $sql = 'UPDATE '.$tbl['admin_accounts'].' SET admin_pwd="'.md5(md5($_POST['new_pwd'])).'" WHERE id='.$admin_session['admin_id'];
		 $DB->query($sql);
		?>
		<table width="96%"  border="0" cellspacing="0" cellpadding="1" align="center">
		  <tr>
			<td height="70" align="center" style="font-size:10px;font-family:MS Shell Dlg ">
				OK! Your password has been changed.<br/>
		    	You can login using new password from now on.
			</td>
		  </tr>
		  <tr>
			<td align="center" >
			<input type="button" value=" OK " class="button" onClick="window.close()"  />
			</td>
		  </tr>
		</table>
		<?php
		$show_content = false;
	}
	else  $message = "<font color='red' style=\"font-size:11px\">ERROR! Your current password is incorrect!</font>";
}

if(@$show_content)
{
	?>
	<script language="javascript">
	function jsloading()
	{
		wait.style.display = "inline";
		//document.frm_upload.upload.disabled = true;
		return true;
	}
	</script>
	<table width="96%"  border="0" cellspacing="0" cellpadding="1" align="center">
	<form name="frm_change" method="post" action="change_pwd.php" enctype="multipart/form-data" onSubmit="return jsloading();">
	<tr>
	  <td colspan="2"  style="font-size:11px; font-family:MS Shell Dlg" align="center"><?php echo $message?>&nbsp;</td>
	  </tr>
	<tr>
	<tr>
	  <td colspan="2"  style="font-size:11px; font-family:MS Shell Dlg">Please input your all fields below:</td>
	  </tr>
	<tr>
	  <td width="35%"  style="font-size:11px; font-family:MS Shell Dlg">Current password:</td>
	  <td width="65%"><input type="text" name="old_pwd" size="30" style="font-size:11px;font-family:tahoma " /></td>
	</tr>
	<tr>
		<td  style="font-size:11px; font-family:MS Shell Dlg">New password:</td>
		<td ><input type="text" name="new_pwd" size="30" style="font-size:11px;font-family:tahoma " /></td>
	  </tr>
	  <tr>
		<td  style="font-size:11px; font-family:MS Shell Dlg">&nbsp;</td>
		<td><input type="submit" name="update"  id="update" value="Change password" class="button"  />
			<input type="button" value="Cancel" class="button" onClick="window.close()"  />
			<div id="wait" style="display:none" align="right"><img src="../images/loading.gif"></div>		</td>
	  </tr>
	</form>
	</table>
	<?php
}
?>

</body>
</html>
<?php
$DB->close();
ob_end_flush();
?>